package com.eway.viewanimator;

import android.animation.ObjectAnimator;
import android.animation.PropertyValuesHolder;
import android.animation.TypeEvaluator;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.widget.TextView;

public class ProertyValuesHolder_Activity extends AppCompatActivity {

	private TextView customTv;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_proerty_values_holder_);
		customTv = findViewById(R.id.custom_tv);

		PropertyValuesHolder propertyValuesHolder = PropertyValuesHolder.ofObject("TextChart",
				new charEvaluator(), new Character('a'), new Character('z'));
		ObjectAnimator objectAnimator = ObjectAnimator.ofPropertyValuesHolder(customTv, propertyValuesHolder);
		objectAnimator.setDuration(2000);
		objectAnimator.start();

	}

	private class charEvaluator implements TypeEvaluator<Character> {

		@Override
		public Character evaluate(float fraction, Character startValue, Character endValue) {
			int startChart = (int) startValue;
			int endChart = (int) endValue;

			int currentValue = (int) (startValue + (endValue - startValue) * fraction);
			char result = (char) currentValue;
			return result;
		}
	}
}
